<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>Document</title>
	<style type="text/css">
	
	.box{
		width: 1900px;
		height: 300px;
	}
	
	</style>
	
	<script type="text/javascript">
	
	window.onload = function(){
		
		var start = document.getElementById('start') ;

		var box = document.getElementsByClassName('box') ;

		var paddingLeft=0;
		
		var a = 1;

		function run(){
			
			if (a==1) {
				
				paddingLeft +=2;
			
				if (paddingLeft>1500) {
					
					a=0;
				};
			}else{
				
				paddingLeft -=2;

				if (paddingLeft<0) {
					
					a=1;
				};
			};

			box[0].style.paddingLeft = paddingLeft+'px';
		}

		var start = document.getElementById('start') ;

		var b = 1

		start.onclick = function(){
			
			if (b==1) {
				
				time = setInterval(run, 5)

				start.value="停止";

				b = 0;
			
			}else{

				clearInterval(time);

				start.value='开始';

				b = 1;
			};
		}
	}
	
	</script>
</head>
<body>
	<input type="button" value="开始" id="start">
	<div class="box"><img src="dog.png" alt=""></div>
</body>
</html>